﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Microsoft.HomeServer.HomeServerConsoleTab.TV4Home.Server.WHS.AddIn.Controls
{
    public partial class SetupAndConfigurationSingleStepUserControl : UserControl
    {
        #region Fields
        private Utils.ComponentVerifier.VerificationStatus _state;
        #endregion

        #region Constructor
        public SetupAndConfigurationSingleStepUserControl()
        {
            InitializeComponent();
        }
        #endregion

        #region Properties
        public Utils.ComponentVerifier.VerificationStatus State
        {
            get
            {
                return _state;
            }
            set
            {
                _state = value;

                switch (_state)
                {
                    case Utils.ComponentVerifier.VerificationStatus.NotInstalled:
                        this.pbStateImage.Image = Microsoft.HomeServer.Controls.CommonSettings.InformationImage32x32;
                        break;
                    case Utils.ComponentVerifier.VerificationStatus.Error:
                        this.pbStateImage.Image = Microsoft.HomeServer.Controls.CommonSettings.ErrorImage32x32;
                        break;
                    case Utils.ComponentVerifier.VerificationStatus.Warning:
                        this.pbStateImage.Image = Microsoft.HomeServer.Controls.CommonSettings.WarningImage32x32;
                        break;
                    case Utils.ComponentVerifier.VerificationStatus.Installed:
                        this.pbStateImage.Image = Microsoft.HomeServer.Controls.CommonSettings.GreenCheckImage32x32;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("value");
                }
            }
        }

        public string MessageText
        {
            get { return this.lblMessage.Text; }
            set { this.lblMessage.Text = value; }
        }

        public string CustomActionLinkText
        {
            get
            {
                return lnkInvokeAction.Text;
            }
            set
            {
                lnkInvokeAction.Text = value;

                if (!String.IsNullOrEmpty(value))
                {
                    this.lnkInvokeAction.Visible = true;
                    this.lnkInvokeAction.LinkArea = new LinkArea(0, value.Length);
                }
                else
                {
                    this.lnkInvokeAction.Visible = false;
                }
            }
        }
        public Action CustomAction { get; set; }
        #endregion

        private void lnkInvokeAction_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (CustomAction != null)
                CustomAction.Invoke();
        }
    }
}
